package com.guigu.contentservice.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.guigu.common.utils.R;
import com.guigu.contentservice.entity.Advertisement;
import com.guigu.contentservice.service.AdvertisementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 广告表（管理PC端和小程序端的广告展示） 前端控制器
 * </p>
 *
 * @author zcy
 * @since 2025-09-27
 */
@RestController
@RequestMapping("/content/advertisement")
public class AdvertisementController {
    @Autowired
    private AdvertisementService advertisementService;

    @GetMapping("/queryAllAdvertisement")
    public List<Advertisement> queryAllAdvertisement(){
        return advertisementService.list();
    }

  /**
   * 前台-查询所有的轮播图
   * */
  @GetMapping("/selectallAdvertisement_PC")
  public R selectallAdvertisement_PC(){

      QueryWrapper<Advertisement> advertisementQueryWrapper = new QueryWrapper<>();
      advertisementQueryWrapper.eq("ad_type",1);
      advertisementQueryWrapper.eq("status",1);

      List<Advertisement> list = advertisementService.list(advertisementQueryWrapper);

      return  R.ok().data("list",list);
  }

    /**
     * 前台-查询所有小程序的轮播图
     */

  @GetMapping("/selectallAdvertisement_APP")
    public R selectallAdvertisement_APP(){

      QueryWrapper<Advertisement> advertisementQueryWrapper = new QueryWrapper<>();
      advertisementQueryWrapper.eq("ad_type",0);
      advertisementQueryWrapper.eq("status",1);

      List<Advertisement> list = advertisementService.list(advertisementQueryWrapper);

      return  R.ok().data("list",list);
  }
}
